from django.conf.urls import patterns, url, include
from rest_framework.urlpatterns import format_suffix_patterns
from api.views import UserList, UserDetail, GroupList, GroupDetail, PermissionList, PermissionDetail, ContentTypeList, ContentTypeDetail, MachineList, MachineDetail, ReportList, ReportDetail, InventoryItemList, InventoryItemDetail, CatalogList, CatalogDetail, ManifestList, ManifestDetail


urlpatterns = patterns('api.views',
    url(r'^$', 'api_root'),
    url(r'^users/$',
        UserList.as_view(), name='user-list'),
    url(r'^users/(?P<pk>\d+)/$',
        UserDetail.as_view(), name='user-detail'),
    url(r'^groups/$',
        GroupList.as_view(), name='group-list'),
    url(r'^groups/(?P<pk>\d+)/$',
        GroupDetail.as_view(), name='group-detail'),
    url(r'^permissions/$',
        PermissionList.as_view(), name='permission-list'),
    url(r'^permissions/(?P<pk>\d+)/$',
        PermissionDetail.as_view(), name='permission-detail'),
    url(r'^contenttypes/$',
        ContentTypeList.as_view(), name='contenttype-list'),
    url(r'^contenttypes/(?P<pk>\d+)/$',
        ContentTypeDetail.as_view(), name='contenttype-detail'),
    url(r'^machines/$',
        MachineList.as_view(), name='machine-list'),
    url(r'^machines/(?P<pk>[^/]+)$',
        MachineDetail.as_view(), name='machine-detail'),
    url(r'^reports/$',
        ReportList.as_view(), name='report-list'),
    url(r'^reports/(?P<pk>\d+)/$',
        ReportDetail.as_view(), name='munkireport-detail'),
    url(r'^inventory/$',
        InventoryItemList.as_view(), name='inventoryitem-list'),
    url(r'^inventory/(?P<pk>\d+)/$',
        InventoryItemDetail.as_view(), name='inventoryitem-detail'),
    url(r'^catalogs/$',
        CatalogList.as_view(), name='catalog-list'),
    url(r'^catalogs/(?P<catalog_name>.+)$',
        CatalogDetail.as_view(), name='catalog-detail'),
    url(r'^manifests/$',
        ManifestList.as_view(), name='manifest-list'),
    url(r'^manifests/(?P<manifest_name>.+)$',
        ManifestDetail.as_view(), name='manifest-detail'),
)




# Format suffixes
urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'api'])

# Default login/logout views
urlpatterns += patterns('',
    url(r'^auth/', include('rest_framework.urls', namespace='rest_framework'))
)
